/**
 * Copyright 2021 Huawei Technologies Co., Ltd
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#ifndef MINDSPORE_LITE_TOOLS_CONVERTER_MICRO_CODER_OPCODERS_CMSIS_NN_INT8_FULLCONNECTION_INT8_CODER_H_
#define MINDSPORE_LITE_TOOLS_CONVERTER_MICRO_CODER_OPCODERS_CMSIS_NN_INT8_FULLCONNECTION_INT8_CODER_H_

#include <string>
#include <vector>
#include "coder/opcoders/op_coder.h"
#include "coder/opcoders/base/full_connection_base_coder.h"
#include "nnacl/int8/quantize.h"
namespace mindspore::lite::micro::cmsis {
class FullConnectionInt8Coder final : public FullConnectionBaseCoder {
 public:
  FullConnectionInt8Coder(const std::vector<Tensor *> &in_tensors, const std::vector<Tensor *> &out_tensors,
                          const LiteGraph::Node *node, size_t node_index, Target target)
      : FullConnectionBaseCoder(in_tensors, out_tensors, node, node_index, target) {}

  int Prepare(CoderContext *const context) override;

  int DoCode(CoderContext *const context) override;

  ~FullConnectionInt8Coder() override = default;

 private:
  int SetParameters();
  void ConfigInputOutput();

  uint16_t col_dim_{0};
  uint16_t row_dim_{0};
  uint16_t nb_batches_{0};
  int32_t input_offset_{0};
  int32_t filter_offset_{0};
  int32_t out_multiplier_{0};
  int32_t out_shift_{0};
  int32_t output_offset_{0};
  int32_t output_activation_min_{0};
  int32_t output_activation_max_{0};
};
}  // namespace mindspore::lite::micro::cmsis
#endif  // MINDSPORE_LITE_TOOLS_CONVERTER_MICRO_CODER_OPCODERS_CMSIS_NN_INT8_FULLCONNECTION_INT8_CODER_H_
